package com.test.dao.impl;

import com.test.dao.IHeatBaseDao;
import com.test.model.HeatBase;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by ZZF on 2017/8/9.
 */
@Repository
public class HeatBaseDaoImpl extends BaseDaoImpl<HeatBase> implements IHeatBaseDao {


    @Override
    public List<HeatBase> findHouseMeter() {

        String sql = "SELECT * FROM rcc_o_heatbase a WHERE a.equType='户表' AND ISNULL(a.baseDate)  ";

        Query query = getSession().createSQLQuery(sql).addEntity(HeatBase.class);

        return query.list();
    }

    @Override
    public List<HeatBase> findBuildMeter() {

        String sql = "SELECT * FROM rcc_o_heatbase a WHERE a.equType='楼表' AND ISNULL(a.baseDate) ";

        Query query = getSession().createSQLQuery(sql).addEntity(HeatBase.class);

        return query.list();
    }

    @Override
    public HeatBase findHouseBase(int equId) {

        String sql = "SELECT * FROM rcc_o_heatbase a WHERE a.equType='户表' AND a.equId= "+equId;

        Query query = getSession().createSQLQuery(sql).addEntity(HeatBase.class);

        return (HeatBase)query.uniqueResult();
    }

    @Override
    public HeatBase findBuildBase(int equId) {

        String sql = "SELECT * FROM rcc_o_heatbase a WHERE a.equType='楼表' AND a.equId= "+equId;

        Query query = getSession().createSQLQuery(sql).addEntity(HeatBase.class);

        return (HeatBase)query.uniqueResult();
    }


}
